﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using hello.csharp.helper;
using Microsoft.AspNetCore.Mvc;
using hello.csharp.zone.Models;
using NLog;

namespace hello.csharp.zone.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
        private readonly LogFileParseHelper _helper;

        public HomeController(LogFileParseHelper helper)
        {
            _helper = helper;
        }

        public IActionResult Index()
        {
            return View();
        }

        public IActionResult MsLog()
        {
            ViewData["log"] = _helper.BuildSimpleAllLogTable();
            return View();
        }

        public IActionResult OwnLog()
        {
            ViewData["log"] = _helper.BuildSimpleOwnLogTable();
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel {RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier});
        }
    }
}